package com.tjsinfo.tjsoa.system.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.system.bo.ISystemDutyBo;
import com.tjsinfo.tjsoa.system.vo.TSystemDuty;
/**
 * 添加职位
 * @author 岳晓磊
 *xxx
 */
public class AddDutyAction extends Action {
	private ISystemDutyBo systemDutyBo; 
	public void setSystemDutyBo(ISystemDutyBo systemDutyBo) {
		this.systemDutyBo = systemDutyBo;
	}
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		try {
			String dutyName = request.getParameter("dutyName");
			String dutyDes = request.getParameter("dutyDes");						
			Byte state = 0;
			TSystemDuty tsd = new TSystemDuty();
			tsd.setDutyName(dutyName);
			tsd.setDutyDescription(dutyDes);
			tsd.setIsDel(state);
			if(request.getParameter("jibie") != null && !"".equals(request.getParameter("jibie")))
			{
				Integer levelNo = Integer.parseInt(request.getParameter("jibie"));
				tsd.setLevelNo(levelNo);
			}
			systemDutyBo.save(tsd);
			request.setAttribute("linkurl", "system/duty/dutylist.jsp?fanhui=true");
			request.setAttribute("message", "system.dutySave.message");
			return mapping.findForward("success");
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			request.setAttribute("Exception", e);
			return mapping.findForward("failed");
		}
	}


}
